<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="java.util.*" %>
<html>
<head>
	<title>Add Mom</title>
	<link rel="stylesheet" type="text/css" href="resources/css/css.css">
	<script type="text/javascript" src="resources/js/jquery-1.3.2.min.js"></script>
</head>
<script type="text/javascript">
	jQuery(document).ready(function() {
		
		$('body').keydown(function(e) {
		    if (e.keyCode == 13) {
		    	validForm();
		    }
		});
		document.getElementById("submitForm").onclick = function(){
		    validForm();
		}
	}
	);
	function validForm(){
		num = document.getElementById("num").value;
		price = document.getElementById("price").value;
		if(num != "" && price != "") document.getElementById("form").submit();
		else alert("Number or Price Can't be Null");
	}
</script>
<body>
<h1>
	Add Mom
</h1>
<p><a href="mom">Mom List</a></p>
<c:if test="${!empty momName}">
  Mom name ${momName} added !!
</c:if>
<form action="addMom" method="post" id="form">
		<table >
			<tr>
				<td>Decs
				<select name="decs" id="decs" autofocus="autofocus">
					<option value="top">top</option>
					<option value="down">down</option>
				</select>
				</td>
				<td>num<input type="text" name="num" maxlength="2" id="num" /></td>
				<td>price<input type="text" name="price" id="price" /></td>
				<td colspan="3"><input type="button" value="Add!" id="submitForm"/></td>
			</tr>
		</table>
	</form>




<c:if test="${!empty deleteId && !empty deleteName}">
  Mom id ${deleteId} name ${deleteName} has been Deleted!!
</c:if>
	<table border="1" class="tableList">
		<tr>
			<td>Description</td>
			<td>Number</td>
			<td>Price</td>
			<td>Edit</td>
			<td>Delete</td>
		</tr>
		<c:if test="${!empty moms}">
				<c:forEach items="${moms}" var="mom" begin="0" end="30" varStatus="index">
				
				<tr <c:if test="${index.count  mod 2 eq 0}">class="gray"</c:if>>	
					<td>${mom.decs}</td>
					<td class="t500 bigsize">${mom.num}</td>
					<td class="t300 bigsize">${mom.price}</td>
					<td><a href="editMom?id=${mom.id}">Edit</a></td>
					<td><a href="deleteMom?id=${mom.id}">Delete</a></td>
				</tr>		
				</c:forEach>
		</c:if>
	</table>



</body>
</html>
